/*
 * @Author: taoyuqing
 * @Date: 2022-12-23 01:05:58
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:spree/pages/loginPage/login_page.dart';
import 'package:spree/widgets/common_container.dart';
import 'package:spree/widgets/progress_bar.dart';
import 'package:spree/widgets/vip_content_box.dart';
import 'package:spree/widgets/vip_rectangle_box.dart';

class InfoCenter extends StatefulWidget {
  InfoCenter({Key? key}) : super(key: key);
  @override
  State<InfoCenter> createState() => _InfoCenterState();
}

class _InfoCenterState extends State<InfoCenter> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text('profile page'),
        ),
        body: CommonContainer(
          child: ListView(
            padding: EdgeInsets.only(top: 30),
            children: [
              Container(
                child: Text(
                  'Personal Centre:',
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 18,
                      fontWeight: FontWeight.w800),
                ),
              ),
              VipContentBox(
                margin: EdgeInsets.only(top: 20),
                child: Column(
                  children: [
                    Image.asset(
                      'images/Vector2.png',
                      width: 16,
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20, bottom: 20),
                      child: Text(
                        'Personal Information',
                        style: TextStyle(
                            color: Color(0xFFFFED4A),
                            fontWeight: FontWeight.w800,
                            fontSize: 16),
                      ),
                    ),
                    Image.asset(
                      'images/userAvatar.png',
                      width: 135,
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20),
                      child: Text('User323123131313',
                          style: TextStyle(
                              color: Colors.white,
                              fontWeight: FontWeight.w800,
                              fontSize: 22)),
                    ),
                    _darkBar(icon: Icons.link, text: 'Copy'),
                    _darkBar(
                        width: 290,
                        icon: Icons.settings,
                        text: 'Change Nickname'),
                    _darkBar(
                      width: 290,
                      icon: Icons.history,
                      text: 'Game History',
                      onTap: _toHistory,
                    ),
                  ],
                ),
              ),
              VipContentBox(
                margin: EdgeInsets.only(top: 20),
                child: Column(
                  children: [
                    Image.asset(
                      'images/Award.png',
                      width: 22,
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10, bottom: 10),
                      child: Text(
                        'My VIP Level',
                        style: TextStyle(
                            color: Color(0xFFFFED4A),
                            fontSize: 16,
                            fontWeight: FontWeight.w800),
                      ),
                    ),
                    Image.asset(
                      'images/number1.png',
                      width: 90,
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10),
                      child: ProgressBar(
                        percent: 0,
                        name: 'Deposit Amount',
                        cur: '\$0',
                        totle: '/\$100',
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20),
                      child: ProgressBar(
                        percent: 0,
                        name: 'Bet Amount',
                        cur: '\$0',
                        totle: '/\$800',
                      ),
                    )
                  ],
                ),
              ),
              VipContentBox(
                margin: EdgeInsets.only(top: 20),
                child: Column(
                  children: [
                    Icon(
                      Icons.wallet,
                      color: Colors.white,
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20),
                      child: Text(
                        'Wallets',
                        style: TextStyle(
                            color: Color(0xFFFFED4A),
                            fontSize: 16,
                            fontWeight: FontWeight.w800),
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20),
                      child: Text(
                        'R\$',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 30,
                            fontWeight: FontWeight.w800),
                      ),
                    ),
                    _darkMoneyBar(name: 'BET', number: 'R\$0'),
                    _darkMoneyBar(name: 'Deposit', number: 'R\$0'),
                    Container(
                      width: 250,
                      margin: EdgeInsets.only(top: 20),
                      child: Row(
                        mainAxisSize: MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: [
                          ElevatedButton(
                              style: ButtonStyle(
                                backgroundColor: MaterialStateProperty.all(
                                    Color(0xFF5484FF)),
                              ),
                              onPressed: () {},
                              child: Text('Deposit')),
                          ElevatedButton(
                              style: ButtonStyle(
                                backgroundColor: MaterialStateProperty.all(
                                    Color(0xFFF93967)),
                              ),
                              onPressed: () {},
                              child: Text('Withdraw'))
                        ],
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        ));
  }

  _toHistory() {
    Navigator.pushNamed(context, 'HistoryPage');
  }

  Widget _darkBar(
      {double? width = 140,
      required IconData icon,
      required String text,
      Function? onTap}) {
    return VipRectangleBox(
      onTap: onTap,
      margin: EdgeInsets.only(top: 10),
      width: width,
      height: 40,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(
            icon,
            color: Color(0xFFB0AFEC),
          ),
          Container(
            margin: EdgeInsets.only(left: 10),
            child: Text(
              text,
              style: TextStyle(
                  color: Color(0xFFB0AFEC),
                  fontSize: 16,
                  fontWeight: FontWeight.w800),
            ),
          )
        ],
      ),
    );
  }

  Widget _darkMoneyBar({String? name, String? number}) {
    return VipRectangleBox(
      margin: EdgeInsets.only(top: 20),
      width: 250,
      padding: EdgeInsets.all(10),
      child: Column(
        children: [
          Text(name ?? "",
              style: TextStyle(
                  color: Color(0xFFB0AFEC),
                  fontSize: 12,
                  fontWeight: FontWeight.w800)),
          Container(
            margin: EdgeInsets.only(top: 10),
            child: Text(number ?? '',
                style: TextStyle(
                    color: Color(0xFFFEE355),
                    fontSize: 16,
                    fontWeight: FontWeight.w800)),
          )
        ],
      ),
    );
  }
}
